package com.hx.setting.utils;

import java.lang.reflect.Method;
import java.util.List;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.io.support.PropertiesLoaderSupport;

/**
 * Generate Date : 2014-03-16
 * Generate Version : v3.0
 * Generate Name : Honey v3.1 Test
 * Generate User : THINK
 * JDK Version : 1.5
 */
public class AdminContextAware implements ApplicationContextAware, InitializingBean
{

	@Override
	public void afterPropertiesSet() throws Exception
	{
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
	{
		Context.getInstance().setApplicationContext( applicationContext );
		PropertyPlaceholderConfigurer p = (PropertyPlaceholderConfigurer) applicationContext.getBean( "propertyConfigurer" );
		if ( p instanceof PropertiesLoaderSupport )
		{
			PropertiesLoaderSupport sp = (PropertiesLoaderSupport) p;
			try
			{
				Method method = sp.getClass().getSuperclass().getSuperclass().getDeclaredMethod( "mergeProperties" );
				boolean bool = method.isAccessible();
				method.setAccessible( true );
				Context.getInstance().mergeProperties( (java.util.Properties) method.invoke( sp ) );
				method.setAccessible( bool );
			}
			catch ( Exception e )
			{
				e.printStackTrace();
			}
		}
	}
}
/* Honey v3.1 Test - version:1 - OriginalChecksum:B07754adb89693341527e24651dc30a8c (do not edit this line) */
